import request from '@/utils/request'
import { parseStrEmpty } from "@/utils/ruoyi";
var url = process.env.VUE_APP_SUM_PUB;
// 提交个人认证
export function submitAc(data) {
  return request({
    url: '/user/submitAc',
    method: 'post',
    data: data
  })
}


// 修改个人信息
export function updateUser(data) {
  return request({
    url: '/user/updateUser',
    method: 'post',
    data: data
  })
}


// 修改安全密码
export function updateSafePassword(data) {
  return request({
    url: '/user/updateSafePassword',
    method: 'post',
    data: data
  })
}


// 获取用户详情
export function getUserInfo(userId) {
  return request({
    url: '/user/getUserInfo',
    method: 'get'
  })
}

// 查询用户银行卡
export function getUserBank(userId) {
  return request({
    url: '/user/getUserBank',
    method: 'get'
  })
}


// 查询银行卡分类列表
export function getBankClassList(userId) {
  return request({
    url: '/user/getBankClassList',
    method: 'get'
  })
}






// 查询用户列表
export function listUser(query) {
  return request({
    url: '/system/user',
    method: 'get',
    params: query
  })
}

// 查询用户详细
export function getUser(userId) {
  return request({
    url: '/system/user/' + parseStrEmpty(userId),
    method: 'get'
  })
}

// 查询商户详细
export function getMerchantInfo() {
  return request({
    url: '/system/user/getMerchantInfo',
    method: 'get'
  })
}

// 新增用户
export function addUser(data) {
  return request({
    url: '/system/user',
    method: 'post',
    data: data
  })
}

// // 修改用户
// export function updateUser(data) {
//   return request({
//     url: '/system/user/'+data.id,
//     method: 'put',
//     data: data
//   })
// }

// 获取用户权限
export function getUserPermissions(data) {
  return request({
    url: '/system/user/permissions',
    method: 'get',
    params: data
  })
}

// 设置用户权限
export function SetUserPermissions(data) {
  return request({
    url: '/system/user/permissions',
    method: 'post',
    data: data
  })
}

// 删除用户
export function delUser(userId) {
  return request({
    url: '/system/user/' + userId,
    method: 'delete'
  })
}

// 用户密码重置
export function resetUserPwd(userId, password) {
  const data = {
    userId,
    password
  }
  return request({
    url: '/system/user/resetPwd',
    method: 'post',
    data: data
  })
}

// 用户状态修改
export function changeUserStatus(userId, status) {
  const data = {
    userId,
    status
  }
  return request({
    url: '/system/user/changeStatus',
    method: 'post',
    data: data
  })
}

// 查询用户个人信息
export function getUserProfile() {
  return request({
    url: '/system/user/profile',
    method: 'get'
  })
}

// 修改用户个人信息
export function updateUserProfile(data) {
  return request({
    url: '/system/user/profile',
    method: 'post',
    data: data
  })
}

// 用户密码重置
export function updateUserPwd(oldPassword, newPassword) {
  const data = {
    oldPassword,
    newPassword
  }
  return request({
    url: '/system/user/profile/updatePwd',
    method: 'post',
    data: data
  })
}

// 用户头像上传
export function uploadAvatar(data) {
  return request({
    url: '/file/upload',
    method: 'post',
    data: data
  })
}

// 查询授权角色
export function getAuthRole(userId) {
  return request({
    url: '/system/user/authRole/' + userId,
    method: 'get'
  })
}

// 保存授权角色
export function updateAuthRole(data) {
  return request({
    url: '/system/user/authRole',
    method: 'put',
    params: data
  })
}


//获取oss配置
export function getOssConfig(data) {
  return request({
    url: url + '/upload/oss-direct/oss-token',
    method: 'post',
    data: data,
  })
}




